<?php defined('SYSPATH') or die('No direct script access.');

class Model_Register{

	public function reg($array)
	{
		$auth = Auth::instance();
		$user = ORM::factory('people');
		$role = ORM::factory('addrole');
		
		$user->id = '';
		$user->username = $array['username'];
		$user->email = $array['email'];
		$user->password = $auth->hash_password($array['password']);
		$user->save();
		
		$tmpUser = ORM::factory('user', array('username' => $array['username']));
		$userId = $tmpUser->id;
		
		$role->user_id = $userId;
		$role->role_id = 1;
		$role->save();
	}
	

} // End Welcome
